package com.example.lib_db.db.room.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.bw.lib_db.entity.UserInfo


/**
 * 用户信息的操作Dao，提供CRUD操作
 */
@Dao
interface UserInfoDao {
    @Insert
    suspend fun insertUserInfo(vararg user: UserInfo)//vararg表示可以接收存多个实体,相当于Java中“...”

    @Delete
    suspend fun deleteUserInfo(vararg user:UserInfo)

    @Update
    suspend fun updateUserInfo(vararg user:UserInfo)

    @Query("select * from user_info where user_id=:userId")
    suspend fun queryUserInfoById(userId:Int):UserInfo

    @Query("select * from user_info order by user_id")
    suspend fun queryAllUserInfo():List<UserInfo>
}